﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int not_fengefu(char* arr1, const  char* arr2)
{
	int flang = 1;
	while (*arr2)
	{
		if (*arr1 == *arr2)
		{
			flang = 0;
			return flang;
		}
		arr2++;
	}
	return flang;
}

char* my_strcpy(char* arr1, const char* arr2)
{
	char* ret = arr1;
	while (*arr2)
	{
		*arr1 = *arr2;
		arr1++;
		arr2++;
	}
	*arr1 = '\0';
	return ret;
}

char* my_strtok(char* arr1, const char* arr2)
{
	static char* daohang = NULL;
	if (arr1)
	{
		daohang = arr1;
	}
	else
	{
		arr1 = daohang;
	}
	while (*arr1 && not_fengefu(arr1, arr2))
	{
		arr1++;
	}
	if (*arr1 == '\0')
	{
		return NULL;
	}
	*arr1 = '\0';
	char* ret = daohang;
	daohang = ++arr1;
	return ret;
}

int main()
{
	const char arr1[] = "zheng.yu@hang@qq.com";
	char* arr2 = "@.";
	char arr3[30];

	my_strcpy(arr3, arr1);

	for (char* arr4 = my_strtok(arr3, arr2); arr4 != NULL; arr4 = my_strtok(NULL, arr2))
	{
		printf("%s\n", arr4);
	}

	return 0;
}